package com.gzcstec.product.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

@Slf4j
//必须增加component注解，不然无法接收
@Component
public class MqReceiver {

    /**
     * amqpTemplate第一种方式，直接通过queue进行发送和接收
     * @return
     */
//    @RabbitListener(queuesToDeclare = @Queue("product"))
    public void mqReceiver(String message) {
        log.info("mqReceiver，message={}" , message);
    }

    /**
     * amqpTemplate第二种方式，使用queue绑定exchange，通过key区分不同消息
     * @return
     */
//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue("order"),
//            key = "fruit",
//            exchange = @Exchange("orderEx")
//    ))
    public void mqReceiverFruit(String message) {
        log.info("mqReceiverFruit，message={}" , message);
    }

    /**
     * amqpTemplate第二种方式，使用queue绑定exchange，通过key区分不同消息
     * @return
     */
//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue("order"),
//            key = "computer",
//            exchange = @Exchange("orderEx")
//    ))
    public void mqReceiverComputer(String message) {
        log.info("mqReceiverComputer，message={}" , message);
    }

}
